uniform float time;
uniform float amplitude;
uniform float frequency;

// Normales y tangentes
attribute vec3 rm_Binormal;
attribute vec3 rm_Tangent;


varying vec4 color;

varying vec3 vertex_light_position;
varying vec3 vertex_normal;

void main( void )
{
	// Basic per pixel illumination
	vertex_normal = normalize(gl_NormalMatrix * gl_Normal);
    	vertex_light_position = normalize(gl_LightSource[0].position.xyz);
	// End ppi

	//vec3 fvBinormal       = gl_NormalMatrix * rm_Binormal;
	//vec3 fvTangent        = gl_NormalMatrix * rm_Tangent;


	float r = length(gl_Vertex.xyz); // Got distance from origin
	float amp = -0.006*exp(0.5*r)+0.2*abs(0.5*sin(3.0*time+10.2*r*gl_Vertex.y)+sin(time*0.018*r*gl_Vertex.z));
	
	vec3 normT = normalize(gl_Normal);
	// vec3 normT = normalize(fvTangent);
	// vec3 normT = vertex_normal;
	vec4 displace;
	displace.x = normT.x * amp;
	displace.y = normT.y * amp - r*0.1;
	displace.z = normT.z * amp         + sin(0.4*r);
	displace.w = 0.0;

	if ((displace.y + gl_Vertex.y) < 0.0) {
		displace.y = -0.95 * gl_Vertex.y;
	}
	color = vec4(0.8,0.3,0.2,1);
color = vec4(0.75,0.6,0.8,1);
	gl_Position = gl_ModelViewProjectionMatrix * (gl_Vertex + displace);
}